package com.fenger.servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
 * @PackageName: com.fenger.servlet
 * @ClassName: MyServlet
 * @Description:
 * @author: fang
 * @date: 2021/10/31 9:02
 */
public class MyServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletConfig servletConfig = this.getServletConfig();
        Enumeration<String> initParameterNames = servletConfig.getInitParameterNames();
        ServletContext servletContext = servletConfig.getServletContext();
//        servletContext.addServlet("my", new MyServlet());
        HttpSession session = req.getSession();
        Object xx = session.getAttribute("xx");
        PrintWriter writer = resp.getWriter();
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().write("<html>");
        resp.getWriter().write("<head>");
        resp.getWriter().write("</head>");
        resp.getWriter().write("<body><title>this is my page</title><h1>this is my page</h1>");
        resp.getWriter().write("<a href='./user'>toUser</a>");
        resp.getWriter().write("</body>");
        resp.getWriter().write("</html>");
        writer.close();
    }
}
